'use strict';

/**
 * @ngdoc function
 * @name jgappApp.controller:AttendanceAttendanceLogCtrl
 * @description
 * # AttendanceAttendanceLogCtrl
 * Controller of the jgappApp
 */
angular.module('jgappApp')
    .controller('AttendanceAttendanceLogCtrl', function ($routeParams, $location, ContactInfo ,localStorageService, DataService, openApi, Util) {
        var vm = this;
        var type = parseInt($routeParams.type);
        this.buildUrl = function () {
            var tmpName;
            switch (type) {
                case 0:
                case 1:
                case 2:
                case 3:
                case 4:
                case 5:
                case 6:
                    tmpName = 'other';
                    break;
                // case 6:
                //     tmpName = 'overtime';
                //     break;
                default:

            }
            return 'views/attendance/logtemp/' + tmpName + '.html';
        }
        this.show_location = function (lat, lng, distance) {
            $location.path("attendance/show_location/" + lat + "/" + lng + "/" + distance)
        };
        var init = function () {
            getcontactInfo();
        };
        var getDetail = function () {
            var param = {};
            var attLog = localStorageService.get("attLog");
            // vm.UserInfo = Util.getBaseUserInfo();
            param.acId = attLog.value;
            param.year = attLog.name;
            param.month = attLog.text;
            param.flag = type;
            // param.userId = vm.UserInfo.userId;
            DataService.getData(openApi.attLogDetail, param).then(function (data) {
                vm.lists = data;
            })
        };
        var getcontactInfo = function () {
             ContactInfo.getData().then(function (data) {
               getDetail()
            })
        };
        init()
        vm.map = [
            {
                value: 1,
                name: "正常"
            }, {
                value: 2,
                name: "迟到"
            }, {
                value: 3,
                name: "早退"
            },
            // {
            //     value: 4,
            //     name: "未签到"
            // },{
            //     value: 5,
            //     name: "未签退"
            // },
            {
                value: 0,
                name: "范围外"
            }, {
                value: 4,
                name: "加班"
            }];
        vm.map.filter(function (item) {
            if (item.value == type) {
                vm.titletip = "(" + item.name + ")";
            }
        });
    });
